package interceptors;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import java.util.Map;

/**
 *
 * @author corneliugosa
 */
public class ChangePass implements Interceptor{

    @Override
    public void destroy() {
        System.out.println("Destroyed!");
    }

    @Override
    public void init() {
        System.out.println("Initialized!");
    }

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        Map<String,Object> session = invocation.getInvocationContext().getSession();
        
        if(session==null || session.get("passwordChanged")==null){
            return "failure";
        }else if(session.get("passwordChanged").equals("yes")){
            invocation.invoke();
        }
        
        return "failure";
    }
    
}
